﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using FarseerPhysics.Dynamics;

namespace GaugeEngine.Behaviours
{
    public struct PhysicsDescription
    {
    }

    public class PhysicsObject : OnEventBehaviour
    {
        private Body m_body;

        public PhysicsObject(Actor a, World w, PhysicsDescription pd)
            : base(a)
        {
            m_body = new Body(w);
        }

        public override void Handler(Events.EventData eventData)
        {
            switch (eventData.ID)
            {
                case "KeyPress_Left":
                    {
                        m_body.ApplyForce(new Microsoft.Xna.Framework.Vector2(-4, 0));
                        break;
                    }
                case "KeyPress_Right":
                    {
                        m_body.ApplyForce(new Microsoft.Xna.Framework.Vector2(4, 0));
                        ParentActor.Position.X += 1.0f;
                        break;
                    }
            }
        }

        public override void Update(GameTime gameTime)
        {
            ParentActor.Position = new Vector(m_body.Position);
        }
    }
}
